package com.xbongbong.pro.enums.menu.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.MenuTypeEnum;
import com.xbongbong.pro.enums.AccessLinkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/1/16 10:44
 * @desrcption crm的菜单内容
 * @since v1.0
 */
@Getter
public enum CRMMenuEnum {

    //客户
    CUSTOMER_MANAGEMENT("enum.cRMMenu.name.customer_management", XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(),
            XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), AccessLinkEnum.CUSTOMER_MANAGEMENT,  "", MenuTypeEnum.GROUP.getType()),
    CUSTOMER("enum.cRMMenu.name.customer", XbbRefTypeEnum.CUSTOMER.getAlias(), XbbRefTypeEnum.CUSTOMER.getCode(),
            AccessLinkEnum.CUSTOMER,
            XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), MenuTypeEnum.FORM.getType()),

    CUSTOMER_FOCUS("enum.cRMMenu.name.customer_focus", XbbRefTypeEnum.CUSTOMER_FOCUS.getAlias(),  XbbRefTypeEnum.CUSTOMER_FOCUS.getCode(),
            AccessLinkEnum.IMPORTANT_CUSTOMER,
            XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), MenuTypeEnum.FORM.getType()),

    CUSTOMER_DEAL("enum.cRMMenu.name.customer_deal", XbbRefTypeEnum.CUSTOMER_DEAL.getAlias(),  XbbRefTypeEnum.CUSTOMER_DEAL.getCode(),
            AccessLinkEnum.DEALING_CUSTOMER,
            XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), MenuTypeEnum.FORM.getType()),

    CUSTOMER_FOLLOW("enum.cRMMenu.name.customer_follow", XbbRefTypeEnum.CUSTOMER_FOLLOW.getAlias(),  XbbRefTypeEnum.CUSTOMER_FOLLOW.getCode(),
            AccessLinkEnum.FOLLOW_UP_CUSTOMER,
            XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), MenuTypeEnum.FORM.getType()),

    CUSTOMER_PUBLIC("enum.cRMMenu.name.customer_public", XbbRefTypeEnum.CUSTOMER_PUBLIC.getAlias(),  XbbRefTypeEnum.CUSTOMER_PUBLIC.getCode(),
            AccessLinkEnum.HIGH_SEA_POOL_CUSTOMER,
            XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), MenuTypeEnum.FORM.getType()),

    CUSTOMER_DUPLICATE("enum.cRMMenu.name.customer_duplicate", XbbRefTypeEnum.CUSTOMER_DUPLICATE.getAlias(),  XbbRefTypeEnum.CUSTOMER_DUPLICATE.getCode(),
            AccessLinkEnum.CUSTOMER_DUPLICATE,
            XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), MenuTypeEnum.MENU.getType()),

    CUSTOMER_RECYCLE("enum.cRMMenu.name.customer_recycle", XbbRefTypeEnum.CUSTOMER_RECYCLE.getAlias(),  XbbRefTypeEnum.CUSTOMER_RECYCLE.getCode(),
            AccessLinkEnum.CUSTOMER_RECYCLE,
            XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), MenuTypeEnum.FORM.getType()),

    CUSTOMER_NEARBY("enum.cRMMenu.name.customer_nearby", XbbRefTypeEnum.CUSTOMER_NEARBY.getAlias(),  XbbRefTypeEnum.CUSTOMER_NEARBY.getCode(),
            AccessLinkEnum.NEAR_BY_CUSTOMER, XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getAlias(), MenuTypeEnum.FORM.getType()),

    CONTACT("enum.cRMMenu.name.contact", XbbRefTypeEnum.CONTACT.getAlias(),  XbbRefTypeEnum.CONTACT.getCode(),
            AccessLinkEnum.CONTACT, "", MenuTypeEnum.FORM.getType()),
    //跟进记录
    CUSTOMER_COMMUNICATE("enum.cRMMenu.name.customer_communicate", XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getAlias(),
            XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), AccessLinkEnum.CUSTOMER_COMMUNICATE, "", MenuTypeEnum.FORM.getType()),

    //访客计划
    COMMUNICATE_PLAN("enum.cRMMenu.name.communicate_plan", XbbRefTypeEnum.COMMUNICATE_PLAN.getAlias(),  XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(),
            AccessLinkEnum.COMMUNICATE_PLAN, "", MenuTypeEnum.FORM.getType()),

    //销售机会
    SALES_OPPORTUNITY("enum.cRMMenu.name.sales_opportunity", XbbRefTypeEnum.SALES_OPPORTUNITY.getAlias(), XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(),
            AccessLinkEnum.SALES_OPPORTUNITY,"", MenuTypeEnum.GROUP.getType()),

    ALL_OPPORTUNITY("enum.cRMMenu.name.all_opportunity", XbbRefTypeEnum.ALL_OPPORTUNITY.getAlias(), XbbRefTypeEnum.ALL_OPPORTUNITY.getCode(),
            AccessLinkEnum.ALL_OPPORTUNITY, XbbRefTypeEnum.SALES_OPPORTUNITY.getAlias(), MenuTypeEnum.FORM.getType()),

    KEY_OPPORTUNITY("enum.cRMMenu.name.key_opportunity", XbbRefTypeEnum.KEY_OPPORTUNITY.getAlias(), XbbRefTypeEnum.KEY_OPPORTUNITY.getCode(),
            AccessLinkEnum.KEY_OPPORTUNITY,
            XbbRefTypeEnum.SALES_OPPORTUNITY.getAlias(), MenuTypeEnum.FORM.getType()),
    QUOTATION("enum.cRMMenu.name.quotation", XbbRefTypeEnum.QUOTATION.getAlias(), XbbRefTypeEnum.QUOTATION.getCode(),
            AccessLinkEnum.QUOTATION, "", MenuTypeEnum.FORM.getType()),
    //合同订单
    CONTRACT("enum.cRMMenu.name.contract",XbbRefTypeEnum.CONTRACT.getAlias(), XbbRefTypeEnum.CONTRACT.getCode(),
            AccessLinkEnum.CONTRACT, "", MenuTypeEnum.FORM.getType()),
    // 退货退款
    REFUND("enum.cRMMenu.name.refund",XbbRefTypeEnum.REFUND.getAlias(), XbbRefTypeEnum.REFUND.getCode(),
            AccessLinkEnum.REFUND, "", MenuTypeEnum.FORM.getType()),
    //签到
    SIGN_IN("enum.cRMMenu.name.sign_in", XbbRefTypeEnum.SIGNIN.getAlias(), XbbRefTypeEnum.SIGNIN.getCode(), AccessLinkEnum.SIGN_IN, "", MenuTypeEnum.MENU.getType()),
    //工作报告
    WORK_REPORT("enum.cRMMenu.name.work_report", XbbRefTypeEnum.WORK_REPORT.getAlias(), XbbRefTypeEnum.WORK_REPORT.getCode(),
            AccessLinkEnum.WORK_REPORT, "", MenuTypeEnum.FORM.getType()),
    //知识库
    KNOWLEDGE_BASE("enum.cRMMenu.name.knowledge_base",XbbRefTypeEnum.KNOWLEDGE_BASE.getAlias(), XbbRefTypeEnum.KNOWLEDGE_BASE.getCode(),
            AccessLinkEnum.KNOWLEDGE_BASE, "", MenuTypeEnum.MENU.getType()),

    COMPETITOR("enum.cRMMenu.name.competitor",XbbRefTypeEnum.COMPETITOR.getAlias(), XbbRefTypeEnum.COMPETITOR.getCode(),
            AccessLinkEnum.COMPETITOR, "", MenuTypeEnum.FORM.getType()),
    ;

    /**
     * saas应用标示解释
     */
    private String name;
    /**
     * saas应用标示
     * @see XbbRefTypeEnum
     */
    private String alias;
    /**
     * @see XbbRefTypeEnum
     */
    private Integer code;
    /**
     * 对应的链接
     */
    private AccessLinkEnum accessLinkEnum;

    /**
     * 父节点，如果没有父节点，则此值为空字符串
     */
    private String parent;

    /**
     * 类型
     * @see MenuTypeEnum
     */
    private Integer type;


    CRMMenuEnum(String name, String alias, Integer code, AccessLinkEnum accessLinkEnum, String parent, Integer type){
        this.name = name;
        this.alias = alias;
        this.code = code;
        this.accessLinkEnum = accessLinkEnum;
        this.parent = parent;
        this.type = type;
    }

    public static CRMMenuEnum  getByAlias(String alias) {
        for(CRMMenuEnum crmMenuEnum: values()) {
            if(crmMenuEnum.getAlias().equals(alias)){
                return crmMenuEnum;
            }
        }
        return null;
    }

    public static CRMMenuEnum getByCode(Integer code) {
        for(CRMMenuEnum crmMenuEnum: values()) {
            if(crmMenuEnum.getCode().equals(code)){
                return crmMenuEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
